a = input().split()
k = 0
nomer = []
k2 = 0
k3 = 0
k4 = 0
k5 = 0
k6 = 0
for i in range(len(a)):
    if a[i] == "one" or a[i] == "two" or a[i] == "three" or a[i] == "four" or a[i] == "five" or a[i] == "six" or a[i] == "seven" or a[i] == "eight" or a[i] == "nine" or a[i] == "zero":
        k = k + 1
    else:
        k6 = k6 + 1
if k != 3 or k6 > 0:
    print("Wrong input")
else:
    for i in range(3):
        if a[i] == "one":
            nomer.append(1)
        elif a[i] == "two":
            nomer.append(2)
        elif a[i] == "three":
            nomer.append(3)
        elif a[i] == "four":
            nomer.append(4)
        elif a[i] == "five":
            nomer.append(5)
        elif a[i] == "six":
            nomer.append(6)
        elif a[i] == "seven":
            nomer.append(7)
        elif a[i] == "eight":
            nomer.append(8)
        elif a[i] == "nine":
           nomer.append(9)
        elif a[i] == "zero":
           nomer.append(0)
    result = ''.join(str(item) for item in nomer)
    b = int(result)
    c = int(result)
    s = int(result)
    while b > 1:
        k4 = 0
        for i in range(1, b + 1):
            if b % i == 0:
                k4 = k4 + 1
        if k4 == 2:        
            k5 = k5 + 1
            break
        else:
            b = b + 1
            k5 = k5 + 1
    while b > 1:
        k2 = 0
        for i in range(1, c + 1):
            if c % i == 0:
                k2 = k2 + 1
        if k2 == 2:        
            k3 = k3 + 1
            break
        else:
            c = int(c) - 1
            k3 = k3 + 1
    if k3 < k5:
        print(c)
    if k5 < k3:
        print(b)
    if k5 == k3:
        if b < c:
            print(b)
        else:
            print(c)
